package com.yanqu.road.entity.activity.newyearbag;

import com.yanqu.road.entity.DataObject;
import com.yanqu.road.entity.FieldTypeAnnotation;

import java.util.concurrent.ConcurrentHashMap;

@FieldTypeAnnotation(tableName = "t_c_new_year_bag_pool")
public class NewYearBagPool extends DataObject {

    @FieldTypeAnnotation(desc = "活动ID", select = true, update = true)
    private int activityId;
    @FieldTypeAnnotation(desc = "各区间用户限制")
    private ConcurrentHashMap<Integer, NewYearBagLimitData> limitDataMap = new ConcurrentHashMap<>();
    @FieldTypeAnnotation(desc = "每天实物限制")
    private ConcurrentHashMap<Integer, NewYearBagShiWuLimitData> shiWuLimitDataMap = new ConcurrentHashMap<>();


    public NewYearBagLimitData getNewYearBagLimitData(int lv) {
        synchronized (this) {
            if (!limitDataMap.containsKey(lv)) {
                NewYearBagLimitData data = new NewYearBagLimitData(lv);
                limitDataMap.put(lv, data);
                setUpdateOption();
            }
            return limitDataMap.get(lv);
        }
    }

    public NewYearBagShiWuLimitData getNewYearBagShiWuLimitData(int day) {
        synchronized (this) {
            if (!shiWuLimitDataMap.containsKey(day)) {
                NewYearBagShiWuLimitData data = new NewYearBagShiWuLimitData(day);
                shiWuLimitDataMap.put(day, data);
                setUpdateOption();
            }
            return shiWuLimitDataMap.get(day);
        }
    }


    public int getActivityId() {
        return activityId;
    }

    public void setActivityId(int activityId) {
        if (this.activityId != activityId) {
            this.activityId = activityId;
            setUpdateOption();
        }
    }

    public ConcurrentHashMap<Integer, NewYearBagLimitData> getLimitDataMap() {
        return limitDataMap;
    }

    public void setLimitDataMap(ConcurrentHashMap<Integer, NewYearBagLimitData> limitDataMap) {
        this.limitDataMap = limitDataMap;
        setUpdateOption();
    }

    public ConcurrentHashMap<Integer, NewYearBagShiWuLimitData> getShiWuLimitDataMap() {
        return shiWuLimitDataMap;
    }

    public void setShiWuLimitDataMap(ConcurrentHashMap<Integer, NewYearBagShiWuLimitData> shiWuLimitDataMap) {
        this.shiWuLimitDataMap = shiWuLimitDataMap;
        setUpdateOption();
    }
}
